﻿using System;
using System.Collections.Generic;
using wojilu.Apps.Qycms.Domain;
using wojilu.Members.Users.Domain;
using wojilu.Web.Controller.Common;
using wojilu.Web.Mvc;
using wojilu.Web.Mvc.Attr;

namespace wojilu.Web.Controller.Admin.Qycms
{
    public class MenuBottonController : BaseController
    {
        private String loadfun { get; set; }

        public MenuBottonController()
        {

        }

        [NonVisit]
        public virtual void menulinklist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
            set("add", to(new MenuController().MenuLinkAdd));
            set("del", to(new MenuController().Delete));
            set("sort", to(new MenuController().Sort));
            set("showhide", to(new MenuController().ShowHide));
        }

        [NonVisit]
        public virtual void menulinkclist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
            set("add", to(new MenuController().MenuLinkAdd));
            set("del", to(new MenuController().Delete));
            set("sort", to(new MenuController().Sort));
            set("showhide", to(new MenuController().ShowHide));
        }

        [NonVisit]
        public virtual void mangerlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
            var powergrouplist = PowerGroup.findAll();
            bind("powergrouplist", powergrouplist);
            set("powernum", user.GroupId);
            set("tabmenubotton", loadHtml(new MenuBottonController().menulinklist));
        }

        [NonVisit]
        public virtual void lanpacklist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
            var list = cdb.findAll<LanPackType>();
            bind("lanpacklist", list);
        }

        [NonVisit]
        public virtual void articlelist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
            var mid = ctx.GetInt("mid");
            var list = new List<Document_Label>();
            if (mid > 0)
            {
                list = Document_Label.find("lng=:l and mid=:m order by id desc").set("l", DefaultLng).set("m", mid).list();
            }
            else
            {
                list = Document_Label.find("lng=:l order by id desc").set("l", DefaultLng).list();
            }
            bind("labellist", list);
            set("dclabelnum", list.Count);
        }

        [NonVisit]
        public virtual void loglist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void skinlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
            set("skinadd", to(new SkinController().SkinAdd));
        }

        [NonVisit]
        public virtual void adverttypelist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
            
        }

        [NonVisit]
        public virtual void advertlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);

        }

        [NonVisit]
        public virtual void languagelist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void sitelist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void grouplist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void modellist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void modelattlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void recomlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void acmessagelist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void subjectlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void typelist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void callinglist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void bbstypelist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

         [NonVisit]
        public virtual void bbsmainlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
         public virtual void formlist()
         {
             User user = ctx.viewer.obj as User;
             setpublic(user);
         }

        [NonVisit]
        public virtual void messlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void formattlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void fileadminlist()
        {
            User user = ctx.viewer.obj as User;
            setpublic(user);
        }

        [NonVisit]
        public virtual void memberlist()
        {
            //setpublic();
            //var list = Member_Class.findAll();
            //bind("memberpuvlist", list);
            //set("pubnum", list.Count);
        }

        private void setpublic(User user)
        {
            var modelPowerGroup = PowerGroup.findById(user.GroupId);
            bind("powergroup", modelPowerGroup);
            set("load", to(new AdminController().Load) + "?");
        }

    }

}
